#!/usr/bin/perl -w

use Sys::Syslog qw(:DEFAULT setlogsock);

%deflist_pri=(
 'naslog_crit','crit',
 'naslog_info','info',
 'naslog_warning','warning',
 'naslog_debug','debug'
);

setlogsock('unix');

$f_naslog=1;

sub nas_syslog {
        my $minor=shift;
        my $pri=shift;
        my $event=shift;
        my $fmt=shift;
        my @args=@_;
        if( $f_naslog == 1 ) {
                openlog( $minor,'pid','local1');
                $f_naslog=0;
        }
        my $priority=$deflist_pri{$pri};
        if(not defined $priority ) {
                $priority='info';
        }

        my $msg=sprintf($fmt,@args);
        $msg=sprintf("%s %d %s",$priority,$event,$msg);
        syslog($priority,$msg);
        return;
}
1;
